#!/bin/sh
#
# Run a simple backup
#   then restore it.
#
TestName="etc-test-root"
. scripts/functions

scripts/cleanup
scripts/copy-test-confs
echo "/etc" >${cwd}/tmp/file-list

start_test

cat <<END_OF_DATA >${cwd}/tmp/bconcmds
@$out /dev/null
messages
@$out ${cwd}/tmp/log1.out
label storage=File
TestVolume001
run job=NightlySave
yes
wait
messages
@#
@# now do a restore
@#
@$out ${cwd}/tmp/log2.out
restore where=${cwd}/tmp/susan-restores select
unmark *
mark *
done
yes
wait
messages
quit
END_OF_DATA

run_susan
check_for_zombie_jobs storage=File
stop_susan

# more cleanup needed below

cd /
${cwd}/bin/btestls -e ${cwd}/scripts/exclude-etc-test etc >${cwd}/tmp/1
cd ${cwd}/tmp/susan-restores
${cwd}/bin/btestls -e ${cwd}/scripts/exclude-etc-test etc >${cwd}/tmp/2
sort <${cwd}/tmp/1 >${cwd}/tmp/original
sort <${cwd}/tmp/2 >${cwd}/tmp/restored
rm -f ${cwd}/tmp/1 ${cwd}/tmp/2
cd ${cwd}
diff ${cwd}/tmp/original ${cwd}/tmp/restored 2>&1 1>/dev/null
if [ $? != 0 ] ; then
   echo " "
   echo " "
   echo "  ===== !!!! etc-test-root failed !!!! ===== "
   echo "  ===== !!!! etc-test-root failed !!!! ===== " >>test.out
   echo " "
else
   echo "  ===== etc-test-root OK ===== "
   echo "  ===== etc-test-root OK ===== " >>test.out
   scripts/cleanup
fi
